<?php

namespace app\admin\model;

use think\Model;


class Exam extends Model
{


    // 表名
    protected $name = 'exam';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'csubjecttype_text'
    ];
    

    public function getCsubjecttypeList()
    {
        return ['1' => __('Csubjecttype 1'), '2' => __('Csubjecttype 2'), '3' => __('Csubjecttype 3')];
    }


    public function getCsubjecttypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['csubjecttype']) ? $data['csubjecttype'] : '');
        $list = $this->getCsubjecttypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function chapter()
    {
        return $this->belongsTo('Chapter', 'ichapterid', 'ichapterid', [], 'LEFT');
    }




}
